﻿using System;
using System.Web.UI.WebControls;

public partial class aspx_advance_default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            using (ds_名师讲堂TableAdapters.tb_讲堂TableAdapter da = new ds_名师讲堂TableAdapters.tb_讲堂TableAdapter())
            {
                this.rpt_advance.DataSource = da.GetData();
                this.rpt_advance.DataBind();
            }
        }
    }

    protected void btn查询_Click(object sender, EventArgs e)
    {
        string[] condition = new string[] { txt讲座题目.Text, txt主讲人.Text, ddl学院.SelectedValue };
        for (int i = 0; i < condition.Length; i++)
        {
            condition[i] = condition[i].Trim();
            if (string.IsNullOrEmpty(condition[i]))
            {
                condition[i] = "%";
            }
            else
            {
                condition[i] = string.Format("%{0}%", condition[i]);
            }
        }
        for (int i = 0; i < this.cbl条件.Items.Count; i++)
        {
            if (!this.cbl条件.Items[i].Selected)
            {
                condition[i + 1] = "%";
            }
        }
        using (ds_名师讲堂TableAdapters.tb_讲堂TableAdapter da = new ds_名师讲堂TableAdapters.tb_讲堂TableAdapter())
        {
            this.rpt_advance.DataSource = da.GetDataBy模糊查询(condition[0], condition[1], condition[2]);
            this.rpt_advance.DataBind();
        }
    }

    protected void rpt_advance_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        Label lbl = e.Item.FindControl("lbl预告") as Label;
        DateTime dt = DateTime.Parse(lbl.ToolTip);
        if (dt > DateTime.Now)
        {
            lbl.Visible = true;
        }
        else
        {
            lbl.Visible = false;
        }
    }
}